package StudyCode.summary.mycollection;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class ReturnsTheSumOfAllTheElementsInTheArray {
	public static int sumWholeArray(int[] array) {
		return sumWholeArrayHelper(0, 0, array);
	}

	private static int sumWholeArrayHelper(int index, int sum, int[] array) {
		if (index > array.length - 1) {
			return sum;
		} else {
			return sum + array[index]
					+ sumWholeArrayHelper(index + 1, sum, array);
		}
	}
}
